package com.wisdytech.ccdserver.common.model;

import com.wisdytech.common.bean.Filter;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

@Data
public class FilterPage extends Filter implements Serializable {

    private static final long serialVersionUID = -3867319088299904979L;
    /**
     * 页大小
     *
     * @default 10
     */
    @NotNull
    private long currentPage = 0;

    /**
     * 数据库偏移量= 当前页数-1  然后乘以每页条数
     *
     * @return
     */
    public long getCurrentPage() {
        long pageNow = super.getPage();
        long limitNow = super.getLimit();
        if (pageNow > 0) {
            return (pageNow - 1) * limitNow;
        }
        return pageNow;
    }

    public void setCurrentPage(long pageLimit) {
        this.currentPage = pageLimit;
    }
}
